import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'
/* Router Modules */
import componentsRouter from './modules/components'
import chartsRouter from './modules/charts'
import tableRouter from './modules/table'
import nestedRouter from './modules/nested'
/**
 * Note: sub-menu only appear when route children.length >= 1
 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html
 *
 * hidden: true                   if set true, item will not show in the sidebar(default is false)
 * alwaysShow: true               if set true, will always show the root menu
 *                                if not set alwaysShow, when item has more than one children route,
 *                                it will becomes nested mode, otherwise not show the root menu
 * redirect: noRedirect           if set noRedirect will no redirect in the breadcrumb
 * name:'router-name'             the name is used by <keep-alive> (must set!!!)
 * meta : {
    roles: ['admin','editor']    control the page roles (you can set multiple roles)
    title: 'title'               the name show in sidebar and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    noCache: true                if set true, the page will no be cached(default is false)
    affix: true                  if set true, the tag will affix in the tags-view
    breadcrumb: false            if set false, the item will hidden in breadcrumb(default is true)
    activeMenu: '/example/list'  if set path, the sidebar will highlight the path you set
  }
 */

/**
 * constantRoutes
 * a base page that does not have permission requirements
 * all roles can be accessed
 */
// function a(){
//     return import('@/views/dashboard/index')
// }
// if(1){
//     import('@/views/dashboard/index')
// }

export const constantRoutes = [{
    path: '/redirect',
    component: Layout,
    hidden: true,
    children: [{
        path: '/redirect/:path(.*)',
        component: () =>
            import('@/views/redirect/index')
    }]
},
{
    path: '/login',
    component: () =>
        import('@/views/login/indexNew'),
    hidden: true
},
// {
//     path: '/loginNew',
//     component: () =>
//         import('@/views/login/indexNew'),
//     hidden: true
// },
{
    path: '/auth-redirect',
    component: () =>
        import('@/views/login/auth-redirect'),
    hidden: true
},
{
    path: '/404',
    component: () =>
        import('@/views/error-page/404'),
    hidden: true
},
{
    path: '/401',
    component: () =>
        import('@/views/error-page/401'),
    hidden: true
},
{
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    children: [{
        path: 'dashboard',
        component: () =>
            import('@/views/dashboard/index'),
        name: '首页',
        meta: { title: '首页', icon: 'home', affix: true }
    },
        // {
        //     path: 'dashboardAps',
        //     component: () =>
        //         import('@/views/dashboard/indexNew'),
        //     name: '首页',
        //     meta: { title: '首页', icon: 'home', affix: true }
        // }
    ]
},
{
    path: '/Loading',
    component: Layout,
    redirect: '/Loading/StuffingForm',
    hidden: true,
    children: [{
        path: 'StuffingForm',
        component: () =>
            import('@/views/Loading/StuffingForm'),
        name: 'StuffingForm',
        meta: { title: '装柜单创建', icon: 'user'}
    },{
        path: 'StuffingFormOpen',
        component: () =>
            import('@/views/Loading/StuffingFormOpen'),
        name: 'StuffingFormOpen',
        meta: { title: '添加装柜单', icon: 'user'}
    }]
},

{
    path: '/profile',
    component: Layout,
    redirect: '/profile/index',
    hidden: true,
    children: [{
        path: 'index',
        component: () =>
            import('@/views/profile/index'),
        name: 'Profile',
        meta: { title: 'Profile', icon: 'user', noCache: true }
    }]
},
{
    path: '/System',
    component: Layout,
    redirect: '/System/editTemplete',
    hidden: true,
    children: [{
        path: 'editTemplete',
        component: () =>
            import('@/views/System/editTemplete'),
        name: 'editTemplete',
        meta: { title: '打印设置', icon: 'user', noCache: true }
    },
    {
        path: 'PageAutoForm',
        component: () =>
            import('@/views/System/PageAutoForm'),
        name: 'PageAutoForm',
        meta: { title: '页面编辑', icon: 'user', noCache: true }
    }]
}, {
    path: '/Common',
    component: Layout,
    redirect: '/Common/MyWork',
    hidden: true,
    children: [{
        path: 'MyWork',
        component: () =>
            import('@/views/Common/MyWork'),
        name: 'MyWork',
        meta: { title: '待办中心', icon: 'user', noCache: true }
    }]
}, {
    path: '/Common',
    component: Layout,
    redirect: '/Common/MyMessage',
    hidden: true,
    children: [{
        path: 'MyMessage',
        component: () =>
            import('@/views/Common/MyMessage'),
        name: 'MyMessage',
        meta: { title: '通知', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesSales',
    component: Layout,
    redirect: '/MesSales/SOrderForm',
    hidden: true,
    children: [{
        path: 'SOrderForm',
        component: () =>
            import('@/views/MesSales/SOrderForm'),
        name: 'SOrderForm',
        meta: { title: '销售订单', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesSales',
    component: Layout,
    redirect: '/MesSales/barcodeForm',
    hidden: true,
    children: [{
        path: 'barcodeForm',
        component: () =>
            import('@/views/MesSales/barcodeForm'),
        name: 'barcodeForm',
        meta: { title: '条码打印', icon: 'user', noCache: true }
    }]
},


{
    path: '/MesSales',
    component: Layout,
    redirect: '/MesSales/SalesBackdeliverForm',
    hidden: true,
    children: [{
        path: 'SalesBackdeliverForm',
        component: () =>
            import('@/views/MesSales/SalesBackdeliverForm'),
        name: 'SalesBackdeliverForm',
        meta: { title: '销售退货订单', icon: 'user', noCache: true }
    }]
},
{
    path: '/Mespurchase',
    component: Layout,
    redirect: '/Mespurchase/PUBackOrderForm',
    hidden: true,
    children: [{
        path: 'PUBackOrderForm',
        component: () =>
            import('@/views/Mespurchase/PUBackOrderForm'),
        name: 'PUBackOrderForm',
        meta: { title: '采购退料单', icon: 'user', noCache: true }
    }]
}, {
    path: '/Mespurchase',
    component: Layout,
    redirect: '/Mespurchase/PUOrderForm',
    hidden: true,
    children: [{
        path: 'PUOrderForm',
        component: () =>
            import('@/views/Mespurchase/PUOrderForm'),
        name: 'PUOrderForm',
        meta: { title: '采购订单', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesSupply',
    component: Layout,
    redirect: '/MesSupply/PUOrderForm',
    hidden: true,
    children: [{
        path: 'PUOrderForm',
        component: () =>
            import('@/views/MesSupply/PUOrderForm'),
        name: 'PUOrderForm',
        meta: { title: '采购订单', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesSales',
    component: Layout,
    redirect: '/MesSales/SalesdeliverForm',
    hidden: true,
    children: [{
        path: 'SalesdeliverForm',
        component: () =>
            import('@/views/MesSales/SalesdeliverForm'),
        name: 'SalesdeliverForm',
        meta: { title: '销售出货单', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesWH',
    component: Layout,
    redirect: '/MesWH/PuInStockForm',
    hidden: true,
    children: [{
        path: 'PuInStockForm',
        component: () =>
            import('@/views/MesWH/PuInStockForm'),
        name: 'PuInStockForm',
        meta: { title: '采购入库', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesWH',
    component: Layout,
    redirect: '/MesWH/PoInbarcode',
    hidden: true,
    children: [{
        path: 'PoInbarcode',
        component: () =>
            import('@/views/MesWH/PoInbarcode'),
        name: 'PoInbarcode',
        meta: { title: '扫描入库', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesPo',
    component: Layout,
    redirect: '/MesPo/PoOrdersForm',
    hidden: true,
    children: [{
        path: 'PoOrdersForm',
        component: () =>
            import('@/views/MesPo/PoOrdersForm'),
        name: 'PoOrdersForm',
        meta: { title: '生产订单', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesPo',
    component: Layout,
    redirect: '/MesPo/PoPlanOrderForm',
    hidden: true,
    children: [{
        path: 'PoPlanOrderForm',
        component: () =>
            import('@/views/MesPo/PoPlanOrderForm'),
        name: 'PoPlanOrderForm',
        meta: { title: '生产日计划', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesPo',
    component: Layout,
    redirect: '/MesPo/PoCountOrderForm',
    hidden: true,
    children: [{
        path: 'PoCountOrderForm',
        component: () =>
            import('@/views/MesPo/PoCountOrderForm'),
        name: 'PoCountOrderForm',
        meta: { title: '生产MPR', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesPo',
    component: Layout,
    redirect: '/MesPo/PoOrderForm',
    hidden: true,
    children: [{
        path: 'PoOrderForm',
        component: () =>
            import('@/views/MesPo/PoOrderForm'),
        name: 'PoOrderForm',
        meta: { title: '生产外发', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesWH',
    component: Layout,
    redirect: '/MesWH/PoInStockForm',
    hidden: true,
    children: [{
        path: 'PoInStockForm',
        component: () =>
            import('@/views/MesWH/PoInStockForm'),
        name: 'PoInStockForm',
        meta: { title: '成品入库单', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesAcc',
    component: Layout,
    redirect: '/MesAcc/AccCollectionMoneyOrderForm',
    hidden: true,
    children: [{
        path: 'AccCollectionMoneyOrderForm',
        component: () =>
            import('@/views/MesAcc/AccCollectionMoneyOrderForm'),
        name: 'AccCollectionMoneyOrderForm',
        meta: { title: '收款单', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesAcc',
    component: Layout,
    redirect: '/MesAcc/AccPaymentMoneyOrderForm',
    hidden: true,
    children: [{
        path: 'AccPaymentMoneyOrderForm',
        component: () =>
            import('@/views/MesAcc/AccPaymentMoneyOrderForm'),
        name: 'AccPaymentMoneyOrderForm',
        meta: { title: '付款单', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesBasic',
    component: Layout,
    redirect: '/MesBasic/BomDetailForm',
    hidden: true,
    children: [{
        path: 'BomDetailForm',
        component: () =>
            import('@/views/MesBasic/BomDetailForm'),
        name: 'BomDetailForm',
        meta: { title: 'BOM管理', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesBasic',
    component: Layout,
    redirect: '/MesBasic/BomPartDetailForm',
    hidden: true,
    children: [{
        path: 'BomPartDetailForm',
        component: () =>
            import('@/views/MesBasic/BomPartDetailForm'),
        name: 'BomPartDetailForm',
        meta: { title: 'BO半成品管理', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesBasic',
    component: Layout,
    redirect: '/MesBasic/PRDTForm',
    hidden: true,
    children: [{
        path: 'PRDTForm',
        component: () =>
            import('@/views/MesBasic/PRDTForm'),
        name: 'PRDTForm',
        meta: { title: '料物资料', icon: 'user', noCache: true }
    }]
},


{
    path: '/MesWH',
    component: Layout,
    redirect: '/MesWH/AdjustStockForm',
    hidden: true,
    children: [{
        path: 'AdjustStockForm',
        component: () =>
            import('@/views/MesWH/AdjustStockForm'),
        name: 'AdjustStockForm',
        meta: { title: '库存调整单', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesWH',
    component: Layout,
    redirect: '/MesWH/GoodsissueStockForm',
    hidden: true,
    children: [{
        path: 'GoodsissueStockForm',
        component: () =>
            import('@/views/MesWH/GoodsissueStockForm'),
        name: 'GoodsissueStockForm',
        meta: { title: '生产领料单', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesWH',
    component: Layout,
    redirect: '/MesWH/CheckStockForm',
    hidden: true,
    children: [{
        path: 'CheckStockForm',
        component: () =>
            import('@/views/MesWH/CheckStockForm'),
        name: 'CheckStockForm',
        meta: { title: '盘点单', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesWH',
    component: Layout,
    redirect: '/MesWH/PoOutStockForm',
    hidden: true,
    children: [{
        path: 'PoOutStockForm',
        component: () =>
            import('@/views/MesWH/PoOutStockForm'),
        name: 'PoOutStockForm',
        meta: { title: '成品出库单', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesSales',
    component: Layout,
    redirect: '/MesSales/SalesBomForm',
    hidden: true,
    children: [{
        path: 'SalesBomForm',
        component: () =>
            import('@/views/MesSales/SalesBomForm'),
        name: 'SalesBomForm',
        meta: { title: '生产BOM', icon: 'MesSales', noCache: true }
    }]
},


{
    path: '/MesSales',
    component: Layout,
    redirect: '/MesSales/SalesPartBomForm',
    hidden: true,
    children: [{
        path: 'SalesPartBomForm',
        component: () =>
            import('@/views/MesSales/SalesPartBomForm'),
        name: 'SalesPartBomForm',
        meta: { title: '生产半成品BOM', icon: 'MesSales', noCache: true }
    }]
},
{
    path: '/Map',
    component: Layout,
    redirect: '/Map/MapForm',
    hidden: true,
    children: [{
        path: 'MapForm',
        component: () =>
            import('@/views/Map/MapForm'),
        name: 'MapForm',
        meta: { title: '货运监控', icon: 'Map', noCache: true }
    }]
}, {
    path: '/Mespurchase',
    component: Layout,
    redirect: '/Mespurchase/PUPriceForm',
    hidden: true,
    children: [{
        path: 'PUPriceForm',
        component: () =>
            import('@/views/Mespurchase/PUPriceForm'),
        name: 'PUPriceForm',
        meta: { title: '报价单', icon: 'user', noCache: true }
    }]
}, {
    path: '/Mespurchase',
    component: Layout,
    redirect: '/Mespurchase/PUPriceReport',
    hidden: true,
    children: [{
        path: 'PUPriceReport',
        component: () =>
            import('@/views/Mespurchase/PUPriceReport'),
        name: 'PUPriceReport',
        meta: { title: '报价明细', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesSupply',
    component: Layout,
    redirect: '/MesSupply/DeliveryForm',
    hidden: true,
    children: [{
        path: 'DeliveryForm',
        component: () =>
            import('@/views/MesSupply/DeliveryForm'),
        name: 'DeliveryForm',
        meta: { title: '送货明细', icon: 'user', noCache: true }
    }]
},
{
    path: '/MesQMS',
    component: Layout,
    redirect: '/MesQMS/IQCcheckupReportForm',
    hidden: true,
    children: [{
        path: 'IQCcheckupReportForm',
        component: () =>
            import('@/views/MesQMS/IQCcheckupReportForm'),
        name: 'IQCcheckupReportForm',
        meta: { title: 'IQC来料检验报告', icon: 'user', noCache: true }
    },
//     {
//         path: 'QMSSelfReportForm',
//         component: () =>
//             import('@/views/MesQMS/QMSSelfReportForm'),
//         name: 'QMSSelfReportForm',
//         meta: { title: '供应商自评报告', icon: 'user', noCache: true } 
//     }
]
}, {
    path: '/MesQMS',
    component: Layout,
    redirect: '/MesQMS/PQCcheckupReportForm',
    hidden: true,
    children: [{
        path: 'PQCcheckupReportForm',
        component: () =>
            import('@/views/MesQMS/PQCcheckupReportForm'),
        name: 'PQCcheckupReportForm',
        meta: { title: 'PQC检验报告', icon: 'user', noCache: true }
    }]
}, 
{
    path: '/MesQMS',
    component: Layout,
    redirect: '/MesQMS/QMSSelfReportForm',
    hidden: true,
    children: [{
        path: 'QMSSelfReportForm',
        component: () =>
            import('@/views/MesQMS/QMSSelfReportForm'),
        name: 'QMSSelfReportForm',
        meta: { title: '供应商自评报告', icon: 'user', noCache: true }
    }]
}, 
{
    path: '/MesQMS',
    component: Layout,
    redirect: '/MesQMS/QAcheckupReportForm',
    hidden: true,
    children: [{
        path: 'QAcheckupReportForm',
        component: () =>
            import('@/views/MesQMS/QAcheckupReportForm'),
        name: 'QAcheckupReportForm',
        meta: { title: 'QA成品检验报告', icon: 'user', noCache: true }
    }]
}, {
    path: '/MesPieceWork',
    component: Layout,
    redirect: '/MesPieceWork/CompleteProcedureRoportForm',
    hidden: true,
    children: [{
        path: 'CompleteProcedureRoportForm',
        component: () =>
            import('@/views/MesPieceWork/CompleteProcedureRoportForm'),
        name: 'CompleteProcedureRoportForm',
        meta: { title: '工序完工报告', icon: 'user', noCache: true }
    }]
},

    //   { 
    //     path: '/MyWork/:id',
    //     component: Recommend
    // }
]

// export const constantRoutesNew = [{
//     path: '/redirect',
//     component: Layout,
//     hidden: true,
//     children: [{
//         path: '/redirect/:path(.*)',
//         component: () =>
//             import('@/views/redirect/index')
//     }]
// },
// {
//     path: '/login',
//     component: () =>
//         import('@/views/login/indexNew'),
//     hidden: true
// },
// {
//     path: '/auth-redirect',
//     component: () =>
//         import('@/views/login/auth-redirect'),
//     hidden: true
// },
// {
//     path: '/404',
//     component: () =>
//         import('@/views/error-page/404'),
//     hidden: true
// },
// {
//     path: '/401',
//     component: () =>
//         import('@/views/error-page/401'),
//     hidden: true
// },
// {
//     path: '/',
//     component: Layout,
//     redirect: '/dashboard',
//     children: [{
//         path: 'dashboard',
//         component: () =>
//             import('@/views/dashboard/indexNew'),
//         name: '首页',
//         meta: { title: '首页', icon: 'home', affix: true }
//     }]
// },

// {
//     path: '/profile',
//     component: Layout,
//     redirect: '/profile/index',
//     hidden: true,
//     children: [{
//         path: 'index',
//         component: () =>
//             import('@/views/profile/index'),
//         name: 'Profile',
//         meta: { title: 'Profile', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/System',
//     component: Layout,
//     redirect: '/System/editTemplete',
//     hidden: true,
//     children: [{
//         path: 'editTemplete',
//         component: () =>
//             import('@/views/System/editTemplete'),
//         name: 'editTemplete',
//         meta: { title: '打印设置', icon: 'user', noCache: true }
//     },
//     {
//         path: 'PageAutoForm',
//         component: () =>
//             import('@/views/System/PageAutoForm'),
//         name: 'editTemplete',
//         meta: { title: '页面编辑', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/Common',
//     component: Layout,
//     redirect: '/Common/MyWork',
//     hidden: true,
//     children: [{
//         path: 'MyWork',
//         component: () =>
//             import('@/views/Common/MyWork'),
//         name: 'MyWork',
//         meta: { title: '待办中心', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/Common',
//     component: Layout,
//     redirect: '/Common/MyMessage',
//     hidden: true,
//     children: [{
//         path: 'MyMessage',
//         component: () =>
//             import('@/views/Common/MyMessage'),
//         name: 'MyMessage',
//         meta: { title: '通知', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesSales',
//     component: Layout,
//     redirect: '/MesSales/SOrderForm',
//     hidden: true,
//     children: [{
//         path: 'SOrderForm',
//         component: () =>
//             import('@/views/MesSales/SOrderForm'),
//         name: 'SOrderForm',
//         meta: { title: '销售订单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesSales',
//     component: Layout,
//     redirect: '/MesSales/barcodeForm',
//     hidden: true,
//     children: [{
//         path: 'barcodeForm',
//         component: () =>
//             import('@/views/MesSales/barcodeForm'),
//         name: 'barcodeForm',
//         meta: { title: '条码打印', icon: 'user', noCache: true }
//     }]
// },


// {
//     path: '/MesSales',
//     component: Layout,
//     redirect: '/MesSales/SalesBackdeliverForm',
//     hidden: true,
//     children: [{
//         path: 'SalesBackdeliverForm',
//         component: () =>
//             import('@/views/MesSales/SalesBackdeliverForm'),
//         name: 'SalesBackdeliverForm',
//         meta: { title: '销售退货订单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/Mespurchase',
//     component: Layout,
//     redirect: '/Mespurchase/PUBackOrderForm',
//     hidden: true,
//     children: [{
//         path: 'PUBackOrderForm',
//         component: () =>
//             import('@/views/Mespurchase/PUBackOrderForm'),
//         name: 'PUBackOrderForm',
//         meta: { title: '采购退料单', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/Mespurchase',
//     component: Layout,
//     redirect: '/Mespurchase/PUOrderForm',
//     hidden: true,
//     children: [{
//         path: 'PUOrderForm',
//         component: () =>
//             import('@/views/Mespurchase/PUOrderForm'),
//         name: 'PUOrderForm',
//         meta: { title: '采购订单', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesSupply',
//     component: Layout,
//     redirect: '/MesSupply/PUOrderForm',
//     hidden: true,
//     children: [{
//         path: 'PUOrderForm',
//         component: () =>
//             import('@/views/MesSupply/PUOrderForm'),
//         name: 'PUOrderForm',
//         meta: { title: '采购订单', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesSales',
//     component: Layout,
//     redirect: '/MesSales/SalesdeliverForm',
//     hidden: true,
//     children: [{
//         path: 'SalesdeliverForm',
//         component: () =>
//             import('@/views/MesSales/SalesdeliverForm'),
//         name: 'SalesdeliverForm',
//         meta: { title: '销售出货单', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesWH',
//     component: Layout,
//     redirect: '/MesWH/PuInStockForm',
//     hidden: true,
//     children: [{
//         path: 'PuInStockForm',
//         component: () =>
//             import('@/views/MesWH/PuInStockForm'),
//         name: 'PuInStockForm',
//         meta: { title: '采购入库', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesWH',
//     component: Layout,
//     redirect: '/MesWH/PoInbarcode',
//     hidden: true,
//     children: [{
//         path: 'PoInbarcode',
//         component: () =>
//             import('@/views/MesWH/PoInbarcode'),
//         name: 'PoInbarcode',
//         meta: { title: '扫描入库', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesPo',
//     component: Layout,
//     redirect: '/MesPo/PoOrdersForm',
//     hidden: true,
//     children: [{
//         path: 'PoOrdersForm',
//         component: () =>
//             import('@/views/MesPo/PoOrdersForm'),
//         name: 'PoOrdersForm',
//         meta: { title: '生产订单', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesPo',
//     component: Layout,
//     redirect: '/MesPo/PoPlanOrderForm',
//     hidden: true,
//     children: [{
//         path: 'PoPlanOrderForm',
//         component: () =>
//             import('@/views/MesPo/PoPlanOrderForm'),
//         name: 'PoPlanOrderForm',
//         meta: { title: '生产日计划', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesPo',
//     component: Layout,
//     redirect: '/MesPo/PoCountOrderForm',
//     hidden: true,
//     children: [{
//         path: 'PoCountOrderForm',
//         component: () =>
//             import('@/views/MesPo/PoCountOrderForm'),
//         name: 'PoCountOrderForm',
//         meta: { title: '生产MPR', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesPo',
//     component: Layout,
//     redirect: '/MesPo/PoOrderForm',
//     hidden: true,
//     children: [{
//         path: 'PoOrderForm',
//         component: () =>
//             import('@/views/MesPo/PoOrderForm'),
//         name: 'PoOrderForm',
//         meta: { title: '生产外发', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesWH',
//     component: Layout,
//     redirect: '/MesWH/PoInStockForm',
//     hidden: true,
//     children: [{
//         path: 'PoInStockForm',
//         component: () =>
//             import('@/views/MesWH/PoInStockForm'),
//         name: 'PoInStockForm',
//         meta: { title: '成品入库单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesAcc',
//     component: Layout,
//     redirect: '/MesAcc/AccCollectionMoneyOrderForm',
//     hidden: true,
//     children: [{
//         path: 'AccCollectionMoneyOrderForm',
//         component: () =>
//             import('@/views/MesAcc/AccCollectionMoneyOrderForm'),
//         name: 'AccCollectionMoneyOrderForm',
//         meta: { title: '收款单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesAcc',
//     component: Layout,
//     redirect: '/MesAcc/AccPaymentMoneyOrderForm',
//     hidden: true,
//     children: [{
//         path: 'AccPaymentMoneyOrderForm',
//         component: () =>
//             import('@/views/MesAcc/AccPaymentMoneyOrderForm'),
//         name: 'AccPaymentMoneyOrderForm',
//         meta: { title: '付款单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesBasic',
//     component: Layout,
//     redirect: '/MesBasic/BomDetailForm',
//     hidden: true,
//     children: [{
//         path: 'BomDetailForm',
//         component: () =>
//             import('@/views/MesBasic/BomDetailForm'),
//         name: 'BomDetailForm',
//         meta: { title: 'BOM管理', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesBasic',
//     component: Layout,
//     redirect: '/MesBasic/BomPartDetailForm',
//     hidden: true,
//     children: [{
//         path: 'BomPartDetailForm',
//         component: () =>
//             import('@/views/MesBasic/BomPartDetailForm'),
//         name: 'BomPartDetailForm',
//         meta: { title: 'BO半成品管理', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesBasic',
//     component: Layout,
//     redirect: '/MesBasic/PRDTForm',
//     hidden: true,
//     children: [{
//         path: 'PRDTForm',
//         component: () =>
//             import('@/views/MesBasic/PRDTForm'),
//         name: 'PRDTForm',
//         meta: { title: '料物资料', icon: 'user', noCache: true }
//     }]
// },


// {
//     path: '/MesWH',
//     component: Layout,
//     redirect: '/MesWH/AdjustStockForm',
//     hidden: true,
//     children: [{
//         path: 'AdjustStockForm',
//         component: () =>
//             import('@/views/MesWH/AdjustStockForm'),
//         name: 'AdjustStockForm',
//         meta: { title: '库存调整单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesWH',
//     component: Layout,
//     redirect: '/MesWH/GoodsissueStockForm',
//     hidden: true,
//     children: [{
//         path: 'GoodsissueStockForm',
//         component: () =>
//             import('@/views/MesWH/GoodsissueStockForm'),
//         name: 'GoodsissueStockForm',
//         meta: { title: '生产领料单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesWH',
//     component: Layout,
//     redirect: '/MesWH/CheckStockForm',
//     hidden: true,
//     children: [{
//         path: 'CheckStockForm',
//         component: () =>
//             import('@/views/MesWH/CheckStockForm'),
//         name: 'CheckStockForm',
//         meta: { title: '盘点单', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesWH',
//     component: Layout,
//     redirect: '/MesWH/PoOutStockForm',
//     hidden: true,
//     children: [{
//         path: 'PoOutStockForm',
//         component: () =>
//             import('@/views/MesWH/PoOutStockForm'),
//         name: 'PoOutStockForm',
//         meta: { title: '成品出库单', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesSales',
//     component: Layout,
//     redirect: '/MesSales/SalesBomForm',
//     hidden: true,
//     children: [{
//         path: 'SalesBomForm',
//         component: () =>
//             import('@/views/MesSales/SalesBomForm'),
//         name: 'SalesBomForm',
//         meta: { title: '生产BOM', icon: 'MesSales', noCache: true }
//     }]
// },


// {
//     path: '/MesSales',
//     component: Layout,
//     redirect: '/MesSales/SalesPartBomForm',
//     hidden: true,
//     children: [{
//         path: 'SalesPartBomForm',
//         component: () =>
//             import('@/views/MesSales/SalesPartBomForm'),
//         name: 'SalesPartBomForm',
//         meta: { title: '生产半成品BOM', icon: 'MesSales', noCache: true }
//     }]
// },
// {
//     path: '/Map',
//     component: Layout,
//     redirect: '/Map/MapForm',
//     hidden: true,
//     children: [{
//         path: 'MapForm',
//         component: () =>
//             import('@/views/Map/MapForm'),
//         name: 'MapForm',
//         meta: { title: '货运监控', icon: 'Map', noCache: true }
//     }]
// }, {
//     path: '/Mespurchase',
//     component: Layout,
//     redirect: '/Mespurchase/PUPriceForm',
//     hidden: true,
//     children: [{
//         path: 'PUPriceForm',
//         component: () =>
//             import('@/views/Mespurchase/PUPriceForm'),
//         name: 'PUPriceForm',
//         meta: { title: '报价单', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/Mespurchase',
//     component: Layout,
//     redirect: '/Mespurchase/PUPriceReport',
//     hidden: true,
//     children: [{
//         path: 'PUPriceReport',
//         component: () =>
//             import('@/views/Mespurchase/PUPriceReport'),
//         name: 'PUPriceReport',
//         meta: { title: '报价明细', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesSupply',
//     component: Layout,
//     redirect: '/MesSupply/DeliveryForm',
//     hidden: true,
//     children: [{
//         path: 'DeliveryForm',
//         component: () =>
//             import('@/views/MesSupply/DeliveryForm'),
//         name: 'DeliveryForm',
//         meta: { title: '送货明细', icon: 'user', noCache: true }
//     }]
// },
// {
//     path: '/MesQMS',
//     component: Layout,
//     redirect: '/MesQMS/IQCcheckupReportForm',
//     hidden: true,
//     children: [{
//         path: 'IQCcheckupReportForm',
//         component: () =>
//             import('@/views/MesQMS/IQCcheckupReportForm'),
//         name: 'IQCcheckupReportForm',
//         meta: { title: 'IQC来料检验报告', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesQMS',
//     component: Layout,
//     redirect: '/MesQMS/PQCcheckupReportForm',
//     hidden: true,
//     children: [{
//         path: 'PQCcheckupReportForm',
//         component: () =>
//             import('@/views/MesQMS/PQCcheckupReportForm'),
//         name: 'PQCcheckupReportForm',
//         meta: { title: 'PQC检验报告', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesQMS',
//     component: Layout,
//     redirect: '/MesQMS/QAcheckupReportForm',
//     hidden: true,
//     children: [{
//         path: 'QAcheckupReportForm',
//         component: () =>
//             import('@/views/MesQMS/QAcheckupReportForm'),
//         name: 'QAcheckupReportForm',
//         meta: { title: 'QA成品检验报告', icon: 'user', noCache: true }
//     }]
// }, {
//     path: '/MesPieceWork',
//     component: Layout,
//     redirect: '/MesPieceWork/CompleteProcedureRoportForm',
//     hidden: true,
//     children: [{
//         path: 'CompleteProcedureRoportForm',
//         component: () =>
//             import('@/views/MesPieceWork/CompleteProcedureRoportForm'),
//         name: 'CompleteProcedureRoportForm',
//         meta: { title: '工序完工报告', icon: 'user', noCache: true }
//     }]
// },

//     //   { 
//     //     path: '/MyWork/:id',
//     //     component: Recommend
//     // }
// ]



/**
 * asyncRoutes
 * the routes that need to be dynamically loaded based on user roles
 */
export const asyncRoutes = [

    // 404 page must be placed at the end !!!
    { path: '*', redirect: '/404', hidden: true }
]

let createRouter

// if (localStorage.getItem('message') == 'aps') {
//     createRouter = () => new Router({
//         // mode: 'history', // require service support
//         scrollBehavior: () => ({ y: 0 }),
//         routes: constantRoutesNew
//     })
// }else{
createRouter = () => new Router({
    // mode: 'history', // require service support
    scrollBehavior: () => ({ y: 0 }),
    routes: constantRoutes,
    // 关闭 vue-router 的警告  
    // warn: false
})
// }

const router = createRouter()

// Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465
export function resetRouter() {
    const newRouter = createRouter()
    router.matcher = newRouter.matcher // reset router
}

export default router